﻿''' <summary>
''' CAD图元数据服务
''' </summary>
Public Class CadEntityDataService

    ''' <summary>
    ''' 保存:保存CAD图元数据到xml
    ''' </summary>
    Public Sub SaveEntityDataToXml(ByRef entityDataTable As DataTable)
        If entityDataTable Is Nothing Then Exit Sub
        Dim sfd As New SaveFileDialog
        Dim fileName As String
        With sfd
            .Title = "保存图元数据到xml"
            .Filter = "CAD图元数据(.xml)|*.xml"
            If .ShowDialog() = DialogResult.OK Then
                fileName = .FileName
                entityDataTable.WriteXml(fileName, XmlWriteMode.WriteSchema)
            End If

        End With
    End Sub


    ''' <summary>
    ''' 打开:打开图元数据XML
    ''' </summary>
    ''' <returns></returns>
    Public Function OpenEntityDataToXml() As DataTable
        Dim ofd As New OpenFileDialog
        Dim fileName As String
        With ofd
            .Title = "打开图元数据xml"
            .Filter = "CAD图元数据(.xml)|*.xml"
            If .ShowDialog() = DialogResult.OK Then
                fileName = .FileName
                Dim dt As New DataTable
                dt.ReadXml(fileName)
                Return dt
            End If
        End With
        Return Nothing
    End Function

End Class
